package com.dlz.systemshop.service.impl;

import com.dlz.systemshop.mapper.GoodsMapper;
import com.dlz.systemshop.pojo.Goods;
import com.dlz.systemshop.service.GoodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GoodServiceImpl implements GoodService {
    @Autowired
    private GoodsMapper goodsMapper;

    @Override
    public Boolean add(Goods goods) {
        Integer result = goodsMapper.insert(goods);
        return result == 1;
    }

    @Override
    public Boolean update(Goods goods) {
        Integer result = goodsMapper.update(goods);
        return result == 1;
    }

    @Override
    public Goods getGoods(Integer id) {
        return goodsMapper.queryGoods(id);
    }

    @Override
    public List<Goods> getGoodsListAll() {
        return goodsMapper.getGoodsListAll();
    }

    @Override
    public List<Goods> findGoodsByPage(Integer currentPage, Integer pageSize) {
        return goodsMapper.findGoodsByPage(currentPage, pageSize);
    }

    @Override
    public Integer getCount() {
        return goodsMapper.getCount();
    }

    @Override
    public Boolean delGoods(Integer id) {
        int result = goodsMapper.delGoods(id);
        return result == 1;
    }
}
